import React from 'react'
import Product from '../../components/Product'
import {connect} from 'dva'

const mapStateToProps=(state)=> {
  return {
    productList: state.product
  }
}

class ProductPage extends React.Component{
  toIndex=()=>{
    this.props.history.push('/')
  }
  render() {
    const { productList, dispatch } =this.props
    console.log(this.props)
    return(
      <div>
        <Product title={'商品列表'}
                 productList={productList.productList}
                 dispatch={dispatch}
        />
        <button onClick={this.toIndex}>去首页</button>
      </div>
    )
  }
}

export default connect(mapStateToProps)(ProductPage)
